package com.company;

public class Main {

    public static void main(String[] args) {
	// write your code here
    }

}
class Solution {
    public boolean isSameTree(TreeNode p, TreeNode q) {
        //两个树都为空
        if(p == null && q == null) return true;
        //其中一棵树为空
        if((p == null && q != null) || (p != null && q == null)) return false;
        //值相同
        if(p.val == q.val) {
            return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);
        }
        //值不同
        return false;
    }
}